
import Pagination from '@/components/pagination';
import mixin from '@/service/mixin';
import SelectAppList from '@/components/select-app-list';
import { keyMap } from '@/config/index';

export default {
    name: 'finance-activity-withdrawal-withdraw-successfully',
    components: {
        Pagination,
        SelectAppList,
    },
    mixins: [mixin],
    data() {
        return {
            keyMap,
            autoLoanDisabled: false,
            form: {
                orderId: '',
                userPhone: '',
                userId: '',
                payChannel: '',
                appName: '',
                withdrawAccount: '',
            },
            rules: {
                orderId: [],
                userPhone: [],
                userId: [],
                withdrawAccount: [],
            },
            showRefuseDialog: false,
            showBatchRefuseButton: false,
            refuseForm: {
                reason: '',
                label: '',
                orderId: '',
            },
            selectedIdList: {
                ids: [],
                orderIds: [],
                list: [],
            },
        };
    },
    methods: {
        // 获取列表数据
        getTableData(page = this.page) {
            const params = this.fillParams(page);
            this.$api.finance.fission.successList(params).then(res => {
                const {status, data, error} = res;
                if ('1' === status && '00000000' === error && data) {
                    this.tableData = data.resultData;
                    this.setPage(data.page, this.page);
                }
                this.tableMaxHeight = document.body.clientHeight - 290;
            });
        },
        // 搜索列表数据
        search() {
            this.page.currentPage = 1;
            this.getTableData();
        },
        // 导出列表数据
        exportExcel() {
            const params = this.fillParams();
            const user = this.$storage.get('user');
            const language = this.$storage.getLocal('language');
            params.language = language;
            params.token = user.token;
            const {$apiConf} = this;
            const url = this.$urlUtil.fillParams(params, $apiConf.baseUrl + $apiConf.urlType.finance.fission.successExcel, ['page']);
            this.$openNewBlank(url);
        },
        // 配置查询和导出参数
        fillParams(page = this.page) {
            const form = this.form;
            const params = {
                orderId: '',
                userPhone: '',
                withdrawAccount: '',
                userId: '',
                payChannel: '',
                appName: '',
                page: {
                    pageNo: page.currentPage,
                    pageSize: this.page.pageSize
                }
            };
            Object.keys(form).forEach(key => {
                if (typeof form[key] === 'string' && form[key]) {
                    form[key] = form[key].trim();
                    params[key] = form[key];
                }
            });
            return params;
        },
    },
    created() {
        this.getTableData();
    }
}
